﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BussinessLib;
using Global;

public partial class Table_ManageTable : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.BtnDel.Enabled = false;
            this.BtnUpdate.Enabled = false;
            TableManager TManager = new TableManager();
            int iResID = int.Parse(Session["resid"].ToString());
             
            this.GridView1.DataSource = TManager.SearchSeatInfo(iResID);
            this.GridView1.DataBind();



        }
    }
    protected void BtnDel_Click(object sender, EventArgs e)
    {
       // TableManager TManager = new TableManager();

        CreateManager Creator = new CreateManager();
        BaseManager TManager = Creator.GetManager(2);

        Table Tab = new Table();
        int iID = int.Parse(Session["id"].ToString());
        Tab.SetID(iID);
         // bool b = TManager.DeleteTable(Tab);
        bool b = TManager.DeleteObject(Tab);
          if (b)
          {
              Response.Write("<script >alert(\" 删除成功！\");</script>");
          }
          int iResID = int.Parse(Session["resid"].ToString());

          TableManager TManagerTrue = (TableManager)TManager;
          this.GridView1.DataSource = TManagerTrue.SearchSeatInfo(iResID);
          this.GridView1.DataBind();
         

    }
    protected void BtnAdd_Click(object sender, EventArgs e)
    {
        Session["flag"] = 0;
        Response.Redirect("AddTable.aspx");

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.BtnDel.Enabled = true;
        this.BtnUpdate.Enabled = true;
        GridViewRow selectRow = this.GridView1.SelectedRow;

        Session["id"] = int.Parse(selectRow.Cells[0].Text.ToString().Trim());

        Session["tablenum"] = selectRow.Cells[1].Text.ToString().Trim();
        Session["consume"] = selectRow.Cells[2].Text.ToString().Trim();
      //  Session["position"]
            
            string a = selectRow.Cells[3].Text.ToString().Trim(); 
        

    }
    protected void BtnUpdate_Click(object sender, EventArgs e)
    {
        Session["flag"] = 1;
        Response.Redirect("AddTable.aspx");




    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect(@"~\Restaurant\ManageRestaurant.aspx");
      
    }
}
